from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.
class User(AbstractUser):
    # username = models.CharField("用户名", max_length=50)
    # password = models.CharField("密码", max_length=100)
    mobile = models.CharField("手机号", max_length=11)
    def __str__(self):
        return self.username
    class Meta:
        db_table = 'user_tb'
        verbose_name = "用户表"
        verbose_name_plural = verbose_name






# 收获地址 表
#        id                 receiver
# 主键，django自动添加     收件人，varchar(50)
class Addr(models.Model):
    receiver = models.CharField("收件人", max_length=50)
    receiver_mobile = models.CharField("手机号", max_length=11)
    receiver_addr = models.CharField("收货地址", max_length=100)
    is_default = models.BooleanField("是否默认", default=False)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="所属用户")

    def __str__(self):
        return self.receiver+" "+ self.receiver_mobile

    class Meta:
        db_table = "addr_tb"
        verbose_name_plural = "收获地址"